<%@ page import="java.util.List" %>
<%--  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/5/19
  Time: 11:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% String path = request.getContextPath();%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<script src="<%=path%>/static/js/jquery-3.5.1.min.js"></script>
<style>
    table tr{
        text-align: center;
    }
</style>
<script>
    $(function () {
        $("#myform").submit(function () {
            var description = $("#description").val();
            if (description==""){
                alert(description);
                return false;
            }
        });
    });
    $(function () {
        $("a[class=link-update]").click(function () {
            var id = $(this).attr("id");
            $.get("<%=path%>/manage/config/update",{id:id},function (resource) {
                $("#hideing").html(resource);
                $("#hide").css("display","block");
            });
        });
    });
</script>
<div id="hideing"></div>
<jsp:include page="/manage/inc/header"/>
<jsp:include page="/manage/inc/menu"/>
<!--/sidebar-->
<div class="main-wrap">

    <div class="crumb-wrap">
        <div class="crumb-list"><i class="icon-font"></i><a href="<%=path%>/manage/index">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">配置管理</span></div>
    </div>
    <div class="search-wrap">
        <div class="search-content">
            <form action="#" method="get" id="myform">
                <table class="search-tab">
                    <tr>
                        <th width="70">关键字:</th>
                        <td><input class="common-text" placeholder="关键字" name="description" id="description" type="text"></td>
                        <td><input class="btn btn-primary btn2" type="submit"></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    <div class="result-wrap">
        <div class="result-content">
            <table class="result-tab" width="100%">
                <tr>
                    <th>ID</th>
                    <th>配置名称</th>
                    <th>设置值</th>
                    <th>默认值</th>
                    <th>描述</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${requestScope.pageInfo.list}" var="config">
                    <tr>
                        <td>${config.id}</td>
                        <td>${config.key}</td>
                        <td id="oldValue">${config.value}</td>
                        <td id="loadingDiv">${config.defaultValue}</td>
                        <td>${config.description}</td>
                        <td>
                            <a class="link-update" href="#" id="${config.id}">修改</a>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <div class="list-page">
                ${requestScope.pageInfo.pages}页
                <a href="<%=path%>/manage/config/list?pageNumber=1" data-pagenum="1">首页 </a>
                <c:if test="${requestScope.pageInfo.pageNum gt 1}">
                    <a href="<%=path%>/manage/config/list?pageNumber=${requestScope.pageInfo.pageNum-1}" data-pagenum="${requestScope.pageInfo.pageNum-1}">上一页</a>
                </c:if>
                <c:forEach begin="1" end="${requestScope.pageInfo.pages}" var="i">
                    <a href="<%=path%>/manage/config/list?pageNumber=${i}" data-pagenum="${i}"
                        <c:if test="${i eq requestScope.pageInfo.pageNum}"> class="current" </c:if>>${i}</a>
                </c:forEach>

                <c:if test="${requestScope.pageInfo.pageNum lt requestScope.pageInfo.pages}">
                    <a href="<%=path%>/manage/config/list?pageNumber=${requestScope.pageInfo.pageNum+1}" data-pagenum="${requestScope.pageInfo.pageNum+1}">下一页</a>
                </c:if>
                <a href="<%=path%>/manage/config/list?pageNumber=${requestScope.pageInfo.pages}" data-pagenum="${requestScope.pageInfo.pages}">尾页 </a>
                ${requestScope.pageInfo.pageNum}/${requestScope.pageInfo.pages}页
            
            </div>
        </div>

    </div>
</div>
<!--/main-->
</div>
<jsp:include page="/manage/inc/footer"/>
